﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace GetTouringPlansData
{
    class TouringPlansData
    {
        private readonly string attractionString = @"http://touringplans.com/{0}/attractions.json";
        private readonly string attractionDetailString = @"http://touringplans.com/{0}/attractions/{1}.json";

        private readonly string parkDiningString = @"http://touringplans.com/{0}/dining.json";
        private readonly string diningDetailString = @"http://touringplans.com/{0}/dining/{1}.json";

        private string GetJSONData(string url)
        {
            using (var webclient = new WebClient())
            {
                webclient.Headers.Add(
                    HttpRequestHeader.Accept, "application/json");

                var response = webclient.DownloadString(url);
                return response;
            }
        }

        internal string GetAttractions(string park)
        {
            string url = string.Format(attractionString, park);

            return GetJSONData(url);
        }

        internal string GetAttractionDetail(string park, string attraction)
        {
            string url = string.Format(attractionDetailString, park, attraction);
            return GetJSONData(url);
        }

        internal string GetParkDinings(string park)
        {
            string url = string.Format(parkDiningString, park);
            return GetJSONData(url);
        }

        internal string GetDiningDetail(string park, string dining)
        {
            string url = string.Format(diningDetailString, park, dining);
            return GetJSONData(url);
        }
    }
}
